<template>
  <teleport to="#loading">
    <div
      class="loading-container d-flex justify-content-center align-items-center"
      :style="{ backgroundColor: background || '' }"
    >
      <div class="loading-content">
        <div class="spinner-border text-primary" role="status">
          <span class="visually-hidden">{{ text || 'loading...' }}</span>
        </div>
        <p class="text-primary small mb-0" v-if="text">{{ text }}</p>
      </div>
    </div>
  </teleport>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import useCreateDom from '@/hooks/useCreateDom'
export default defineComponent({
  props: {
    text: {
      type: String,
      default: 'loading'
    },
    background: {
      type: String
    }
  },
  setup() {
    useCreateDom('loading')
  }
})
</script>
<style scoped>
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.5);
}
.loading-container .loading-content {
  text-align: center;
}
</style>
